<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.User"%>

<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="../images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 系统管理&gt;&gt; 添加职位
</div>

<%
{
%>
<div class="tt">添加职位</div>
<div class="content">
	<table align="center" border="0" width="700" cellpadding="0"
		cellspacing="0">
		<tr>
			<td class="td1" height="35">
				<span style="margin-left: 30px">一级单位：</span>
				<span id="depart1SelectSpan">
				<%@include file="depart_select/depart1_select_section.jsp" %>
				</span>
				<br />
				<span style="margin-left: 30px">二级单位：</span>
				<span id="depart2SelectSpan">
				<%@include file="depart_select/depart2_select_section.jsp" %>
				</span>
				<br />
				<span style="margin-left: 30px">职位：</span>
				<span id="depart3SelectSpan">
				<input id="depart3Name" name="depart3Name" value="" />
				</span>				
			</td>
			<td  class="td1" height="35">				
				<span style="margin-left: 30px">角色：</span>
				<span id="roleSelectSpan">
				<%@include file="role_select/role_select_section.jsp" %>
				</span>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="td1" align="center">
				<input type="button" value="添加" onclick="addDepart3()" />
				<input type="button" value="取消" onclick="cancelAdd()" />
			</td>
		</tr>
	</table>
</div>
<script type="text/javascript">
function selectDepart1() {
	var depart1ID = getElementValueByID('depart1');
	loadPageSection('depart_select/depart2_select_section.jsp', 'depart2SelectSpan', {depart1ID:depart1ID}, false, function(){ selectDepart2();});
}

function selectDepart2() {
	var depart1ID = getElementValueByID('depart1');
	var depart2ID = getElementValueByID('depart2');
}

function cancelAdd(){
	var depart1ID = getElementValueByID('depart1');
	var depart2ID = getElementValueByID('depart2');
	loadPageSection(
			'<%=request.getContextPath()%>'+'/admin/department3_role.jsp', 
			'mainContentDiv', 
			{
				depart1ID:depart1ID, 
				depart2ID:depart2ID
			}, 
			true
	); 	
}

function addDepart3() {
	var depart1ID = getElementValueByID('depart1');
	var depart2ID = getElementValueByID('depart2');
	var depart3Name = getElementValueByID('depart3Name');
	var roleID =  getElementValueByID('role');
	if(depart3Name == '' || depart3Name == null || depart3Name == 'undefined'){
		$.dialog.alert('请先填好职位名');
		return;
	}
	
$.dialog.confirm('您确认添加吗？', function(){
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'add_depart3_process.jsp',
		data:{		
			depart1ID: depart1ID,
			depart2ID: depart2ID,	
			depart3Name: depart3Name,
			roleID: roleID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {					
					$.dialog('添加成功！', function() { 
						loadPageSection(
								'<%=request.getContextPath()%>' + '/admin/department3_role.jsp', 
								'mainContentDiv', 
								{
									depart1ID:depart1ID, 
									depart2ID:depart2ID
								}, 
								true
						); 
					});					
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
});
}
</script>
<%
}
%>

